package com.stan.script.handle;

import com.stan.script.handle.unix.UnixScript;
import com.stan.script.handle.win.WinScript;
import org.springframework.stereotype.Component;

/**
 * @author Junqiang Zhu
 * @date 2024-05-06 11:13
 */
@Component
public class Strategy implements Os {
    public boolean execute() {
        return getStrategy().handle();
    }

    private AbsStrategy getStrategy() {
        if (isWin()) {
            return new WinScript();
        } else if (isUnix()) {
            return new UnixScript();
        } else if (isMac()) {
            return new WinScript();
        } else {
            throw new RuntimeException("Unsupported OS");
        }
    }
}
